package org.lhg.activiti.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.lhg.activiti.model.Group;
import org.lhg.activiti.service.GroupService;
import org.lhg.activiti.util.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/group")
public class GroupController {

    @Autowired
    private GroupService groupService;

    @RequestMapping(value = "/groupComboList")
    public CommonResult<JSONObject> groupComboList(){
        JSONObject result=new JSONObject();
        List<Group> groupList=groupService.find(null);
        JSONArray rows=JSONArray.parseArray(JSON.toJSONString(groupList));
        result.put("rows",rows);
        result.put("success",true);
        return CommonResult.success(result);
    }

}
